import {Injectable, OnInit} from '@angular/core';
import {Title} from '@angular/platform-browser';
import {SystemService} from './system.service';

@Injectable({
    providedIn: 'root'
})
export class TitleService {
    subTitle = '';
    showSubTitle = false;

    constructor(private titleService: Title,
                private systemService: SystemService) {
        this.systemService.getSysParam('SYSTEM_TITLE').subscribe(v => {
            this.title = v.message;
        });
    }

    private _title = '';

    get title(): string {
        return this._title;
    }

    set title(value: string) {
        this._title = value;
        this.titleService.setTitle(value);
    }
}
